package cn.monkey.chat.server.data;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;

import java.io.Serializable;
import java.util.function.Function;

/**
 * 一次构建之后不允许修改
 *
 * @param <T>
 */
@Getter
@Builder(access = AccessLevel.PACKAGE)
public class Result<T> implements Serializable {
    private Integer code;
    private String msg;
    private T data;


    public <R> Result<R> map(Function<T, R> mapper) {
        return Results.ok(mapper.apply(this.data));
    }
}
